<template>
  <el-form ref="formRef" :model="form" v-loading="loading">
    <pub-edit-description :ndColumns="2">
      <pub-edit-description-item :span="2" label="姓名" required>
        <el-form-item prop="name" :rules="$formRules.input">
          <pub-input v-model="form.name" />
        </el-form-item>
      </pub-edit-description-item>
      <pub-edit-description-item :span="2" label="身份证号" required>
        <el-form-item prop="idCard" :rules="$formRules.idCard">
          <pub-input @change="changeIdCard" v-model="form.idCard" />
        </el-form-item>
      </pub-edit-description-item>
      <pub-edit-description-item :span="2" label="性别" required>
        <el-form-item prop="sexCode" :rules="$formRules.select">
          <pub-select-dict
            v-model="form.sexCode"
            dict-code="XB"
            placeholder="请选择"
            width="100%"
          />
        </el-form-item>
      </pub-edit-description-item>
      <pub-edit-description-item :span="2" label="与老人关系" required>
        <el-form-item prop="relationshipCode" :rules="$formRules.select">
          <pub-select-dict
            v-model="form.relationshipCode"
            dict-code="JSGX"
            placeholder="请选择"
            width="100%"
          />
        </el-form-item>
      </pub-edit-description-item>
      <pub-edit-description-item :span="2" label="联系方式" required>
        <el-form-item prop="contactNumber" :rules="$formRules.phoneOrNum">
          <pub-input v-model="form.contactNumber" />
        </el-form-item>
      </pub-edit-description-item>
    </pub-edit-description>
    <div class="dialog-footer-btn">
      <el-button type="default" @click="emit('cancel')">取消</el-button>
      <el-button type="primary" @click="submit" v-prevent-repeat-click>
        保存
      </el-button>
    </div>
  </el-form>
</template>
    <script setup>
import { formatDictCode } from '@/utils/index'
import { ElMessage, ElMessageBox } from 'element-plus'
import { calAgeAndSexByIdCard, validateIdCardMethods } from '@/utils'
import dayjs from 'dayjs'
const emit = defineEmits(['cancel', 'success'])
const props = defineProps({
  status: {
    type: [String, Number],
    default: '1'
  },
  id: {
    type: String,
    default: ''
  },
  // SQ社区服务站管理 JD街道中心管理
  pageName: {
    type: String,
    default: 'SQ'
  }
})
const form = ref({
  operatorDate: ''
})
const loading = ref(false)

const changeIdCard = ()=>{
  form.value.sexCode = calAgeAndSexByIdCard(form.value.idCard, 2)
}
const formRef = ref(null)
const submit = async () => {
  formRef.value.validate(async valid => {
    if (valid) {
      loading.value = true
        ElMessage({
          type: 'success',
          message: '添加成功！'
        })
        emit('success', 'addListDialog',form.value)
      
      loading.value = false
    }
  })
}

onMounted(() => {})
</script>
    <style lang="scss" scoped></style>
    